import datetime

from django.shortcuts import render


def index(request):
    # context = {
    #     'city': '北京',
    #     'adict': {
    #         'name': '西游记',
    #         'author': '吴承恩'
    #     },
    #     'alist': [1, 2, 3, 4, 5]
    # }
    # 接收数据

    context = {
        'name': '小明',
        'age': 20,
        'gender': '男',
        'title': '<script src="/static/xx.js"></script>',  # xss
        'date': datetime.datetime.now()
    }
    return render(request, 'index.html', context)


def index2(request):
    return render(request, 'son.html')


def index3(request):
    # 处理get,
    # 1. 获取数据
    age = int(request.GET.get('age'))
    # 2. 渲染页面
    if age >= 18:
        text = '成年'
    else:
        text = '未成年'

    return render(request, 'index3.html', {'text': text, 'age':age})
